// call 参数一个个
Function.prototype.mycall = function (context = window, ...args) {
    if (this == Function.prototype) {
        return undefined  // 防止Funtion.prototype.mycall 自己调用
    }
    const fn = Symbol();
    context[fn] = this;
    const result = context[fn](...args);
    delete context[fn];
    return result
}


// apply 参数数组
Function.prototype.myAlpply = function (context = window, args) {
    if (this == Function.prototype) {
        return undefined  // 防止Funtion.prototype.mycall 自己调用
    }
    const fn = Symbol();
    context[fn] = this;
    const result
    if(Array.isArray(args)){
        result = context[fn](args);
    }else {
        result = context[fn]();
    }
    delete context[fn];
    return result
}


// bind 参数是一个一个的
Function.prototype.myBind = function(context, ...args1){
    if(this === Function.prototype){
        throw new TypeError("Error");
    }
    const _this = this;
    return function F(...args2){
        //  判断是否用于构造函数
        if(this instanceof F){
            return new _this(...args1,...args2)
        }
        return _this.apply(context, args1.concat(args2))
    }
}